/*++

Copyright (c) 2012 Minoca Corp.

    This file is licensed under the terms of the GNU General Public License
    version 3. Alternative licensing terms are available. Contact
    info@minocacorp.com for details. See the LICENSE file at the root of this
    project for complete licensing information.

Module Name:

    crash.h

Abstract:

    This header contains definitions for fatal system error codes.

Author:

    Evan Green 25-Sep-2012

--*/

//
// ---------------------------------------------------------------- Definitions
//

//
// This is not a valid crash code.
//

#define CRASH_INVALID                       0x0
#define CRASH_PAGE_FAULT                    0x1
#define CRASH_PAGE_FAULT_AT_HIGH_RUN_LEVEL  0x2
#define CRASH_PAGE_IN_ERROR                 0x3
#define CRASH_PAGE_OUT_ERROR                0x4
#define CRASH_SYSTEM_INITIALIZATION_FAILURE 0x5
#define CRASH_HARDWARE_LAYER_FAILURE        0x6
#define CRASH_IPI_FAILURE                   0x7
#define CRASH_INVALID_IRP                   0x8
#define CRASH_THREAD_ERROR                  0x9
#define CRASH_POOL_CORRUPTION               0xA
#define CRASH_ACPI_FAILURE                  0xB
#define CRASH_WORK_ITEM_CORRUPTION          0xC
#define CRASH_DPC_FAILURE                   0xD
#define CRASH_KTIMER_FAILURE                0xE
#define CRASH_KERNEL_STACK_EXCEPTION        0xF
#define CRASH_DIVIDE_BY_ZERO                0x10
#define CRASH_OUT_OF_MEMORY                 0x11
#define CRASH_DRIVER_ERROR                  0x12
#define CRASH_USB_ERROR                     0x13
#define CRASH_PAGING_DEVICE_REMOVAL         0x14
#define CRASH_MATH_FAULT                    0x15
#define CRASH_ILLEGAL_INSTRUCTION           0x16

//
// Call this macro to take the system down.
//

#define KeCrashSystem(_CrashCode,  \
                      _Parameter1, \
                      _Parameter2, \
                      _Parameter3, \
                      _Parameter4) \
                                   \
    KeCrashSystemEx(_CrashCode,    \
                    #_CrashCode,   \
                    _Parameter1,   \
                    _Parameter2,   \
                    _Parameter3,   \
                    _Parameter4)

//
// -------------------------------------------------------- Function Prototypes
//

KERNEL_API
VOID
KeCrashSystemEx (
    ULONG CrashCode,
    PCSTR CrashCodeString,
    ULONGLONG Parameter1,
    ULONGLONG Parameter2,
    ULONGLONG Parameter3,
    ULONGLONG Parameter4
    );

/*++

Routine Description:

    This routine officially takes the system down after a fatal system error
    has occurred. This function does not return. Do not call this routine
    directly, use the non-Ex version, a macro that calls this routine with the
    correct string.

Arguments:

    CrashCode - Supplies the reason for the system crash.

    CrashCodeString - Supplies the string corresponding to the given crash
        code. This parameter is generated by the macro, and should not be
        filled in directly.

    Parameter1 - Supplies an optional parameter regarding the crash.

    Parameter2 - Supplies an optional parameter regarding the crash.

    Parameter3 - Supplies an optional parameter regarding the crash.

    Parameter4 - Supplies an optional parameter regarding the crash.

Return Value:

    None. This function does not return.

--*/

